<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text" indent="yes" /> 
  <xsl:strip-space elements="td h2"/> 
  <xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable>


  <xsl:template match="/">

<xsl:for-each select="//section[@class='fields']">
  <xsl:variable name="section_id"><xsl:value-of select="@id" /></xsl:variable>
  <xsl:variable name="section_file"><xsl:value-of select="normalize-space(h2)" /></xsl:variable>
<xsl:value-of select="$newline" /><!-- xsl:value-of select="$section_id"/>, --><!-- <xsl:value-of select="$section_file" />,
--><xsl:for-each select="table/tr/td[@scope='row']/.."><xsl:value-of select="$section_file" />,<xsl:value-of select="td[position()=1]/@id" />,<xsl:value-of select="normalize-space(td[position()=1])" />,<xsl:value-of select="normalize-space(td[position()=2])" />,<xsl:value-of select="normalize-space(td[position()=3])" />,
</xsl:for-each></xsl:for-each>

  <!--
  <xsl:variable name="section_id"><xsl:value-of select="@id" /></xsl:variable>
  <xsl:variable name="section_file"><xsl:value-of select="normalize-space(h2)" /></xsl:variable>
<xsl:value-of select="$section_file" />( "<xsl:value-of select="$section_file" />",
  <xsl:for-each select="table/tr/td[@scope='row']/.."> "<xsl:value-of select="normalize-space(td[position()=1])" />",</xsl:for-each>),
</xsl:for-each>
-->
  
</xsl:template>

</xsl:stylesheet>
